package com.hxgz.Interceptor;

import com.hxgz.filter.JwtFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

@Component
public class LoginInterceptor extends HandlerInterceptorAdapter {

  @Autowired
  private JwtFilter jwtFilter;

 /* @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(jwtFilter).addPathPatterns("/**").excludePathPatterns("")

  }*/






 /* public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
      Object handler) {
    //負責把請求令牌解析
    try {
      User user = Const.checkUserLogin(request);
      if (user != null) {
        if (user.getRole() == 1) {
          request.setAttribute("user", user);
        } else {
          request.setAttribute("backUser", user);
        }
      } else {
        response.reset();
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json;charset=UTF-8");
        PrintWriter pw = response.getWriter();
        pw.write(JsonUtil
            .obj2String(ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),
                ResponseCode.NEED_LOGIN.getDesc())));
        pw.flush();
        pw.close();
      }
    } catch (Exception e) {
      throw new RuntimeException("令牌错误");
    }
    return true;
  }*/

}
